<template>
  <div class="other-settings views-container">
    <div class="wlm-form">
      <div class="wlm-form-header">设置</div>
      <div class="wlm-form-content">
        <el-form
          ref="platform"
          :model="formFormatData.formData"
          :rules="formFormatData.rules"
          size="small"
          label-width="180px"
          class="retail-form"
          label-position="right"
        >
          <el-form-item label="启用炮灰域名">
            <!-- v-model="formFormatData.formData.app_show" -->
            <el-radio-group
              v-model="formFormatData.formData.status"
              @change="statusbtn"
            >
              <el-radio :label="0">不启用</el-radio>
              <el-radio :label="1">启用</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item
            label="独立授权域名"
            v-if="formFormatData.formData.status == 1"
          >
            <el-input
              v-model="formFormatData.formData.v.oauth_domain"
              placeholder="请输入独立授权域名"
              style="width:80%;"
            ></el-input>
            <div class="form-help">注：一般为您的主域名不需要加http或者https，需要填写至公众号网页授权中，此域名不会被移动端访问，故不会被腾讯封禁。</div>
          </el-form-item>
          <el-form-item
            label="炮灰域名"
            v-if="formFormatData.formData.status == 1"
          >
            <el-input
              type="textarea"
              :rows="10"
              v-model.trim="formFormatData.formData.v.domains"
              style="width:80%;"
            ></el-input>
            <div class="form-help">
              <p>
                1.多个炮灰域名可以随机跳转,多个域名请用|隔开,不需要加http或者https，如：y1.baidu.com|y2.baidu.com|y3.baidu.com|y4.baidu.com|y5.baidu.com。
              </p>
              <p>
                2.炮灰域名最多5个，因为腾讯规定js安全域名最多5个。
              </p>
              <p>
                3.解析的炮灰域名必须指向您的服务器IP。
              </p>
              <p>4.所有的域名都必须加到js安全域名里面，否则会分享失败。</p>
              <p>5.所有炮灰域名必须加到支付授权目录里，否则可能导致无法支付。</p>
            </div>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
      <el-button size="small" @click="saveForm" type="primary">保存</el-button>
    </div>
  </div>
</template>
<script>
import {
  saveDomainSetting,
  getDomainSetting,
  getDomainRecord,
  deleteDomainRecord
} from "@/api/operation";
import mixins from "@/mixins/mixins";

export default {
  mixins: [mixins.getters("Form")],
  name: "cannonfodder",
  data() {
    return {
      formFormatData: {
        api: {
          editForm: {
            api: getDomainSetting,
            params: {
              always: true
            }
          },
          submitForm: saveDomainSetting
        },
        formData: {
          status: 0,
          v: {
            oauth_domain: "",
            domains: ""
          }
        }
      }
    };
  },
  methods: {
    saveForm() {
      // 保存到你要的那个form值里面
      this.formFormatSubmit();
    },
    statusbtn() {
      if (this.formFormatData.formData.status == 0) {
        this.formFormatData.formData.oauth_domain = "";
        this.formFormatData.formData.domains = "";
      }
    }
  }
};
</script>
